package net.xxcxcxcx.xc_enhancedmob.register.client;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.minecraft.screen.PlayerScreenHandler;
import net.minecraft.util.Identifier;
import net.xxcxcxcx.xc_enhancedmob.register.ParticlesRegister;
import net.xxcxcxcx.xc_enhancedmob.render.particle.custom.CustomBaseParticle;
import net.xxcxcxcx.xc_enhancedmob.render.particle.custom.CustomDirectionBaseParticle;

import static net.xxcxcxcx.xc_enhancedmob.EnhancedMobMod.ModId;

@Environment(value = EnvType.CLIENT)
public class ParticlesRenderRegister {
    @Environment(value = EnvType.CLIENT)
    public static void Registry() {
        texture();
        factory();
    }

    @Environment(value = EnvType.CLIENT)
    public static void texture() {
        ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).register(((atlasTexture, registry) -> {
            registry.register(new Identifier(ModId, "particle/custom_base"));
        }));
        ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).register(((atlasTexture, registry) -> {
            registry.register(new Identifier(ModId, "particle/custom_direction_base"));
        }));
    }

    @Environment(value = EnvType.CLIENT)
    public static void factory() {
        ParticleFactoryRegistry.getInstance().register(ParticlesRegister.CUSTOM_BASE_PARTICLE, CustomBaseParticle.Factory::new);
        ParticleFactoryRegistry.getInstance().register(ParticlesRegister.CUSTOM_DIRECTION_BASE_PARTICLE, CustomDirectionBaseParticle.Factory::new);
    }
}